package com.hong.chapter4;

/**
 * Created by hong on 2018/6/1.
 * 守护线程测试
 * */
public class DaemonThread {
    public static void main(String[] args) throws InterruptedException {

        Thread t = new Thread(){
            @Override
            public void run() {

                try {
                    System.out.println(Thread.currentThread().getName()+"running");
                    Thread.sleep(10000);
                    System.out.println(Thread.currentThread().getName()+"done");
                }catch (Exception e){
                    e.printStackTrace();
                }

            }
        };//new
        /*将此线程标记为守护线程 */
        t.setDaemon(true);
        t.start();//runnable running deadl ->blocked
        Thread.sleep(5_000);
        System.out.println(Thread.currentThread().getName());
    }
}
/*
*   A<----------------------------->B
*    ->daemonThread(health check)
*
* */
